package com.wantong.jianpu.models;

import com.trello.rxlifecycle2.LifecycleProvider;
import com.wantong.jianpu.beans.LoginBean;
import com.wantong.jianpu.beans.UpLoadBean;
import com.wantong.jianpu.net.BaseObserver;
import com.wantong.jianpu.net.HttpUtils;
import com.wantong.jianpu.net.RetrofitUtil;

import java.util.List;
import java.util.Map;

import io.reactivex.Observable;
import me.goldze.mvvmhabit.base.BaseModel;

/**
 * @author PACY
 * @date 2022/5/23
 * description:
 */
public class UpLoadModel extends BaseModel {
    /**
     * 上传图片
     *
     * @param filePath
     * @param observer
     * @param lifecycle
     */
    public void upLoadImage(String filePath, BaseObserver<UpLoadBean> observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().upLoadFile( HttpUtils.buildUpLoad(filePath));
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }

    /**
     * 批量上传图片
     *
     * @param filePath
     * @param observer
     * @param lifecycle
     */
    public void upLoadImages(List<String> filePath, BaseObserver<List<UpLoadBean>> observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().upLoadFiles( HttpUtils.buildUpLoads(filePath));
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }
}
